import React, { useState } from 'react';
import contextObj from './context';
import Son from './Son'
const { Provider } = contextObj;

const Mycontext = () => {
    const [useinfo, setuserInfo] = useState({
        name: "罗纳尔多",
        age: 30
    });
    return (
        <div>
            <p>祖先组件</p>
            <p>
                <button onClick={() => {
                    setuserInfo({
                        ...useinfo,
                        age: useinfo.age + 1
                    })
                }}>修改userinfo数据</button>
            </p>
            <Provider value={useinfo}>
                <Son></Son>
            </Provider>
        </div>
    );
}

export default Mycontext;
